package net.lab1024.sa.admin.module.business.yct.yctofficial.controller;

import net.lab1024.sa.admin.module.business.category.domain.form.CategoryTreeQueryForm;
import net.lab1024.sa.admin.module.business.category.domain.vo.CategoryTreeVO;
import net.lab1024.sa.admin.module.business.yct.yctofficial.domain.form.YctOfficialInfoClassAddForm;
import net.lab1024.sa.admin.module.business.yct.yctofficial.domain.form.YctOfficialInfoClassQueryForm;
import net.lab1024.sa.admin.module.business.yct.yctofficial.domain.form.YctOfficialInfoClassUpdateForm;
import net.lab1024.sa.admin.module.business.yct.yctofficial.domain.vo.YctOfficialInfoClassTreeVO;
import net.lab1024.sa.admin.module.business.yct.yctofficial.domain.vo.YctOfficialInfoClassVO;
import net.lab1024.sa.admin.module.business.yct.yctofficial.service.YctOfficialInfoClassService;
import net.lab1024.sa.admin.module.business.yct.yctproductinstructions.domain.vo.YctProductInstructionsVO;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 易齿通官网类目 Controller
 *
 * @Author zahngben
 * @Date 2024-09-23 10:00:32
 * @Copyright 01
 */

@RestController
@Tag(name = "易齿通官网类目")
public class YctOfficialInfoClassController {

    @Resource
    private YctOfficialInfoClassService yctOfficialInfoClassService;

    @Operation(summary = "分页查询 @author zahngben")
    @PostMapping("/yctOfficialInfoClass/queryPage")
    @SaCheckPermission("yctOfficialInfoClass:query")
    public ResponseDTO<PageResult<YctOfficialInfoClassVO>> queryPage(@RequestBody @Valid YctOfficialInfoClassQueryForm queryForm) {
        return ResponseDTO.ok(yctOfficialInfoClassService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author zahngben")
    @PostMapping("/yctOfficialInfoClass/add")
    @SaCheckPermission("yctOfficialInfoClass:add")
    public ResponseDTO<String> add(@RequestBody @Valid YctOfficialInfoClassAddForm addForm) {
        return yctOfficialInfoClassService.add(addForm);
    }

    @Operation(summary = "更新 @author zahngben")
    @PostMapping("/yctOfficialInfoClass/update")
    @SaCheckPermission("yctOfficialInfoClass:update")
    public ResponseDTO<String> update(@RequestBody @Valid YctOfficialInfoClassUpdateForm updateForm) {
        return yctOfficialInfoClassService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author zahngben")
    @PostMapping("/yctOfficialInfoClass/batchDelete")
    @SaCheckPermission("yctOfficialInfoClass:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return yctOfficialInfoClassService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author zahngben")
    @GetMapping("/yctOfficialInfoClass/delete/{classId}")
    @SaCheckPermission("yctOfficialInfoClass:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long classId) {
        return yctOfficialInfoClassService.delete(classId);
    }

    @Operation(summary = "查询类目层级树 ")
    @PostMapping("/yctOfficialInfoClass/tree")
    @NoNeedLogin
    public ResponseDTO<List<YctOfficialInfoClassTreeVO>> queryTree(@RequestBody @Valid YctOfficialInfoClassQueryForm queryForm) {
        return yctOfficialInfoClassService.queryTree(queryForm);
    }
    @NoNeedLogin
    @GetMapping("/yctOfficialInfoClass/select/{classId}")
    public ResponseDTO<YctOfficialInfoClassVO> select(@PathVariable Long classId) {
        return ResponseDTO.ok(yctOfficialInfoClassService.select(classId));
    }
}
